package free.play.validation;

import free.play.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class PhoneNumberValidator implements ConstraintValidator<PhoneNumber, String> {

  @Autowired
  private UserRepository userRepository;

  public PhoneNumberValidator() {
    System.out.println("create PhoneNumberValidator instance");
  }

  @Override
  public void initialize(PhoneNumber phoneNumber) {


  }

  @Override
  public boolean isValid(String s, ConstraintValidatorContext constraintValidatorContext) {

    return s!=null && s.length() == 11;
  }
}
